home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / STANDALO / COMMENTF / ABOUT_CO.MME next >
Text File  |  1990-04-22  |  4KB  |  108 lines

  1.  
  2.  
  3. About the CommentFKEY...
  4.  
  5. This is an FKEY to make it easier for C programmers to comment portions
  6. of their code.  This is mainly for documentation purposes, but it
  7. does help a with debugging, because you can quicky comment in and
  8. out suspect portions.
  9.  
  10. Install the FKEY in your System file using ResEdit, or open the file
  11. with Suitcase or a similar utility.  The FKEY is currently numbered 6,
  12. but that can be changed.
  13.  
  14. Select the portion of text you want commented, copy it to the clipboard,
  15. and hit command-shift-6. If you hit no other keys for 3/4 of a second, 
  16. the FKEY will do its default operation.  By pressing other keys before 
  17. 3/4 of a second expires, you can make other choices; they are described below.
  18.  
  19. The default choice is to surround the text with a box like this:
  20. /*----------------------------------------------------------------------------+
  21. |                                                                             |
  22. |    This text is surrounded with a box.  It stands out on the screen.         |
  23. |    It looks important!                                                       |
  24. |                                                                             |
  25. +----------------------------------------------------------------------------*/
  26.  
  27. If the text you select already has the top and bottom of the box in it, they
  28. will be ignored.  This way you can edit boxed text, select it and re-box
  29. it without needing to delete the top and bottom lines.  It's a little
  30. hard to describe how it works, but you'll see when you play with it.
  31.  
  32. NOTE: this FKEY works best if you select entire lines, including end-of-line
  33. characters.
  34.  
  35. If you press the option key within 3/4 of a second after calling the FKEY,
  36. the text will be indented with a tab, and a line of marks will be
  37. placed to its left, like this:
  38.             /*
  39.             *    This text has a line going down its left side.
  40.             *    It doesn't look so important, but is good for
  41.             *    writing short notes.
  42.             */
  43.                             /*
  44.                             *    The line starts at the same indent level
  45.                             *    as the text was originally.
  46.                             */
  47. Like the box feature, this will try to determine if the text was already
  48. given a line before, and if so, do the smart thing.  You can edit
  49. text with a line on its left and call the FKEY again.  As before, it's
  50. easier for you to play with it than for me to describe it.
  51.  
  52. If you press the tab key within 3/4 of a second, the text will be surrounded
  53. with /* and */ characters on separate lines, and any existing comments will
  54. be replaced with |* and *| (this is because C doesn't allow commented comments,
  55. or at least my C compiler doesn't).  Example:
  56. /*
  57.         if ( *inT == '/' && *(inT+1) == '*' ) {
  58.             |* skip this line *|
  59.             while ( inT < endT && *inT != '\r' ) { inT++; }
  60.             if ( inT < endT )
  61.                 inT++;
  62.             continue;
  63.         }
  64.         
  65.         if ( (*inT == '*' && *(inT+1) == '/') ||
  66.             (*inT == '/' && *(inT-1) == '*') ) {
  67.             |* skip this line *|
  68.             while ( inT < endT && *inT != '\r' ) { inT++; }
  69.             if ( inT < endT )
  70.                 inT++;
  71.             continue;
  72.         }
  73. */
  74. This way, you can select a portion of code and temporarily comment
  75. it out without worrying about any comments already in the code.
  76.  
  77. If you press the "`" key within 3/4 of a second after calling the FKEY,
  78. it will be assumed that the text on the clipboard was previously
  79. commented with the tab key.  It will remove anything outside the first
  80. level of comments (/* and */), and replace any |* and *| strings with
  81. /* and */; it undoes what the tab key does.  If the text you copy
  82. has no /* and */ characters, the FKEY just replaces any |* and *|
  83. strings it finds.
  84.  
  85. BUGS:
  86.  
  87. 1) The behavior of the FKEY is designed mainly for my tastes, but the
  88. source is included so you can change it if you'd like.  In particular,
  89. all the commenting characters are #defined, so you can change those and
  90. recompile if you'd like.
  91.  
  92. 2) It doesn't necessarily work right for long lines.
  93.  
  94. 3) If your editor doesn't use the TEScrap or the Desk Scrap, but uses a
  95. private scrap, the FKEY probably won't work.  The only program that I found
  96. did this, though, was Word.  I would guess other word processors do as well.
  97. How to I easily trick a program to put its text on the clipboard?
  98.  
  99. The FKEY and code is free, but is copyrighted 1990 by David Fry and cannot
  100. be resold.  
  101.  
  102. Have fun!
  103.  
  104. David Fry
  105. 81 Irving Street
  106. Cambridge, MA 02138
  107. INTERNET:  fry@math.harvard.edu
  108.